<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>优惠券</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="../../css/mui.css"/>
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="../../css/general.css"/>
		<style type="text/css">
			.hdiv{
				width: 100%;
				padding: 10px;
				margin: 5px auto;
				display: flex;
				justify-content: flex-start;
				align-items: center;
				background-color: white;
			}
			.himg{
				width: 50px;
				height: 50px;
				margin: auto 15px;
			}
			.himg>img{
				width: 100%;
				height: 100%;
				border-radius: 50%;
			}
			.text{
				padding: 5px;
			}
			.quanlist{
				width: 100%;
				background-color: white;
				display: flex;
				align-items: center;
				justify-content: flex-start;
			}
			.d1{
				width: 50%;
				padding: 5px;
				display: flex;
				flex-direction: column;
				align-items: flex-start;
				justify-content: space-between;
				border-right:1px solid #C0C0C0 ;
			}
			.d1>div,.d2>div{
				padding: 2px;
			}
			.d2{
				display: flex;
				flex-direction: column;
				align-items: flex-start;
				justify-content: space-around;
				padding: 5px;
			}
			.checklist{
				background-color: white !important;
				margin: 5px auto;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav hbg">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left colorw"></a>
		    <h1 class="mui-title">优惠券</h1>
		    <div class="hicon mui-icon-right-nav mui-pull-right" id="adddiv">
		    	<img src="../../img/add.png"/>
		    </div>
		</header>
		<div class="mui-content">
		    <div class="" id="qlist">
		    	
		    </div>
		    <div class="fgd"></div>
		    
		</div>
		<script src="../../js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/mui.min.js"></script>
		<script src="../../js/req.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/muishow.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			var mid = 0;
			window.onload = function(){
				
				mui.init();
				mid = getrequest().mid;
				
				g("adddiv").addEventListener("tap",function(){
					mui.openWindow({
						url:'../vouchers.html?mid='+mid,
						id:'vouchers'
					})
					
				});
				
				getmember_coupon();
				
				//getlist(list);
				
				/*document.getElementById('checkall').addEventListener('change',function() {
		            var listBox = mui('.listcheckbox');
		            if (this.checked) {
		                listBox.each(function() {
		                    this.checked = true;
		                })
		            } else {
		                listBox.each(function() {
		                    this.checked = false;
		                })
		            }
		        })*/
				
			}
			
			function getmember_coupon(){
				
				var data = {
					url:"/api/member/detail",
					data:{access_token:acctoken(),id:mid}
				}
				ajax(data,function(res){
					console.log("会员详情",res);
					setmember_coupon(res.data.member_coupon);
				})
			}
			function setmember_coupon(list){
				console.log(list);
				var str = '';
				if(list&&list.length){
				
				for(var i = 0 ; i < list.length ; i++){
					
					str += '<div class="mui-input-row mui-checkbox checklist">'+
		    	    '<label><div class="quanlist"><div class="d1"><div class="fe1">'+
		    		list[i].coupon_name +
		    		'</div><div class="fe12">￥'+
		    		list[i].coupon_money+
		    		'</div></div><div class="d2 fe08"><div class="">'+
		    		list[i].coupon_money+		
		    		'元优惠券</div><div class="">满'+
		    		list[i].coupon_condition +
		    		'可用</div><div class="">到期时间：'+
		    		list[i].end_time+
		    		'</div></div></div></label>'+
		    	    '</div>';
					
				}
				}else{
					str += '<div class="nolistdiv">暂无数据</div>'
				}
				g("qlist").innerHTML = str ;
			}
			
			function setcheckbox(e){
				if(!e.checked){
					//$('#checkall').removeAttribute('checked');
					document.getElementById('checkall').checked = false;
				}
			}
			
			function getlist(list){
				let qlist = document.getElementById("qlist");
				let str = "";
				for (let i = 0; i < list.length;i++) {
				 str +='<div class="mui-input-row mui-checkbox checklist">'+
		    	    '<label><div class="quanlist"><div class="d1"><div class="fe1">'+
		    		list[i].text +
		    		'</div><div class="fe12">￥'+
		    		list[i].nums+
		    		'</div></div><div class="d2 fe08"><div class="">'+
		    		list[i].nums+		
		    		'元代金券</div><div class="">'+
		    		list[i].men +
		    		'</div><div class="">'+
		    		list[i].time+
		    		'</div></div></div></label>'+
		    	    '<input name="Checkbox" class="listcheckbox" type="checkbox" onchange="setcheckbox(this)"></div>';
				}
				qlist.innerHTML = str;
			}
		</script>
	</body>

</html>